package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.TrainMapper;
import com.lune.job.pojo.Train;
import com.lune.job.service.IResumeService;
import com.lune.job.service.ITrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class TrainServiceImpl extends ServiceImpl<TrainMapper, Train> implements ITrainService {

    @Autowired
    private TrainMapper trainMapper;

    @Autowired
    private IResumeService resumeService;

    @Override
    public IPage<Train> queryPage(Integer currentPage, Integer size, Train train) {
        Page<Train> page = new Page<>(currentPage, size);
        IPage<Train> intentionIPage = trainMapper.queryPage(page, train);
        return intentionIPage;
    }

    @Override
    public List<Train> queryByCon(Train train) {
        List<Train>  trains = trainMapper.queryByCon(train);
        trains.forEach(item -> {
            item.setResume(resumeService.getById(item.getResume_id()));
        });
        return trains;
    }
}
